
import React from 'react';
import ReactDOM from 'react-dom';
import { HotTable } from '@handsontable/react';
import Handsontable from 'handsontable';
import {renderAppById} from '../util'
export default class App extends React.Component {
    constructor(props) {
        super(props);
        window.t = this
        this.state = {
            handsontableData: Handsontable.helper.createSpreadsheetData(10, 10)
        }
        this.hotSettings = {
            data: this.handsontableData,
            startRows: 5,
            colHeaders: true,
            colWidths: 222,
            selectionMode: 'multiple',
            /**
             * @method  修改单元格数据后触发
             * @param [*] changes 改变的    数据
             * @param [*] source 来源
             */
            afterSetDataAtCell: (changes,source) => {
                console.log(changes,source)
            }                         
        };
    }

    render() {
        this.hotSettings.data = this.state.handsontableData
        return (
            <div>
                <HotTable
                    id="hot"
                    settings={this.hotSettings}
                />
            </div>
        );
    }
}

// renderAppById('修改单元格数据', App)                  